package com;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author yuhang
 * @desc
 * @since 2022/10/18
 */
public class Test08 {

    public static void main(String[] args) throws Exception {
//        File file = new File("D:/456.txt");
//        BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
//        java.lang.String x = "";
//        StringBuilder sb = new StringBuilder();
//        while ((x = bufferedReader.readLine()) != null) {
//            sb.append(x);
//        }
//
//        List<Map> list = JSONArray.parseArray(sb.toString(), Map.class);
//
//        List<String> ss = new ArrayList<>();
//        for (Map m : list) {
//
//            System.out.println(m.get("productId"));
//            ss.add(String.valueOf(m.get("productId")));
//        }
//
//        System.out.println(ss);
//        System.out.println(ss.size());

//        for (int i = 0; i <= 105; i++) {
//            int tmp = (int) (i % 100);
//            if(tmp!=0){
//                String msg = String.format("%02d", tmp);
//                System.out.println(msg);
//            }
//
//
//        }

//        List<Long> list = new ArrayList<Long>();
//        list.add(3579L);list.add(3578L);list.add(3577L);list.add(3576L);list.add(3570L);list.add(3569L);
//        list.add(3563L);list.add(3562L);list.add(3561L);list.add(3560L);list.add(3557L);list.add(3548L);
//        list.add(3547L);list.add(3544L);list.add(3543L);list.add(3542L);list.add(3541L);list.add(3540L);
//        list.add(1286L);list.add(1475L);list.add(1380L);list.add(1362L);list.add(1349L);list.add(1337L);
//        list.add(1287L);
//
//
//        System.out.println(list);
//        Long milliSecond = LocalDateTime.now().plusMinutes(-58).toInstant(ZoneOffset.of("+8")).toEpochMilli();
//        System.out.println(LocalDateTime.now().plusMinutes(-60));
//        long gap = System.currentTimeMillis() - milliSecond;
//
//        String str = null;
//        if (gap < 60 * 1000) {
//            str = (gap / 1000) + "秒前";
//        } else if (gap > 60 * 1000 && gap < 60 * 60 * 1000) {
//            str = (gap / (1000 * 60)) + "分钟前";
//        } else if (gap > 60 * 60 * 1000 && gap < 24 * 60 * 60 * 1000) {
//            str = (gap / (1000 * 60 * 60)) + "小时前";
//        } else {
//            str = "111";
//        }

//        System.out.println(str);


        String json="{\n" +
                "    \"productIds\":[\n" +
                "        {\n" +
                "            \"id\":3339925,\n" +
                "            \"score\":0.87016444206238\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3339298,\n" +
                "            \"score\":0.86516456604004\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3395135,\n" +
                "            \"score\":0.86394515037537\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3354913,\n" +
                "            \"score\":0.85922899246216\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3382271,\n" +
                "            \"score\":0.85841541290283\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3414720,\n" +
                "            \"score\":0.8565016746521\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3362394,\n" +
                "            \"score\":0.85472850799561\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3408234,\n" +
                "            \"score\":0.85426826477051\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3396913,\n" +
                "            \"score\":0.85329794883728\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3349115,\n" +
                "            \"score\":0.85244483947754\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3350150,\n" +
                "            \"score\":0.85096950531006\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3384935,\n" +
                "            \"score\":0.84684209823608\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3400567,\n" +
                "            \"score\":0.84675664901733\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3321800,\n" +
                "            \"score\":0.84637680053711\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3396881,\n" +
                "            \"score\":0.8442831993103\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":2813397,\n" +
                "            \"score\":0.84398097991943\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3405323,\n" +
                "            \"score\":0.84395499229431\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3389393,\n" +
                "            \"score\":0.8438946723938\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3328252,\n" +
                "            \"score\":0.84384641647339\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3404642,\n" +
                "            \"score\":0.84368753433228\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3415352,\n" +
                "            \"score\":0.8435293674469\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3349164,\n" +
                "            \"score\":0.84343628883362\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3377222,\n" +
                "            \"score\":0.84239325523376\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3365188,\n" +
                "            \"score\":0.8422504901886\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3345164,\n" +
                "            \"score\":0.84183330535889\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3384928,\n" +
                "            \"score\":0.84126143455505\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":2815289,\n" +
                "            \"score\":0.84093379974365\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3358340,\n" +
                "            \"score\":0.8403208732605\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3407324,\n" +
                "            \"score\":0.84003944396973\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3351163,\n" +
                "            \"score\":0.83919534683228\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3376371,\n" +
                "            \"score\":0.83891401290894\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3351322,\n" +
                "            \"score\":0.83833713531494\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3394694,\n" +
                "            \"score\":0.83828835487366\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3414261,\n" +
                "            \"score\":0.83810477256775\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3374566,\n" +
                "            \"score\":0.83740544319153\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3352762,\n" +
                "            \"score\":0.83687591552734\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":2104232,\n" +
                "            \"score\":0.83683815002441\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3368869,\n" +
                "            \"score\":0.83679919242859\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3407182,\n" +
                "            \"score\":0.83677263259888\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3345611,\n" +
                "            \"score\":0.83652353286743\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3265898,\n" +
                "            \"score\":0.83647298812866\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3282498,\n" +
                "            \"score\":0.83561415672302\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3270935,\n" +
                "            \"score\":0.83551149368286\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3312277,\n" +
                "            \"score\":0.83542747497559\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\":3345654,\n" +
                "            \"score\":0.83504056930542\n" +
                "        }\n" +
                "    ],\n" +
                "    \"takePriceMax\":999,\n" +
                "    \"takePriceMin\":25\n" +
                "}";


        Map<String,Object> m= JSON.parseObject(json,Map.class);

        String s =JSON.toJSONString(m.get("productIds"));


        List<Map> ss = JSONArray.parseArray(s,Map.class);

        StringBuilder sb = new StringBuilder();
        for(int i=0;i<ss.size();i++){

            sb.append(ss.get(i).get("id").toString()+",");
        }
        System.out.println(sb.toString());
    }
}



